package com.cw1.design1Single;

/**
 * @Author qiuMi
 * @description 懒汉式(线程不安全)
 * @Date 2022-09-26 22:06
 **/
public class SingleTest03 {
    public static void main(String[] args) {

    }
}

/**
 * 懒汉式 - 线程不安全
 */
class Single3{
    private static Single3 instance;

    /**
     * 当调用 getInstance 才创建单例对象 - 懒汉式
     * @return Single3
     */
    public static Single3 getInstance(){
        if (null == instance){
            instance = new Single3();
        }
        return instance;
    }
}
